package cn.boodqian.airdata;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

public class AirData  {
	public int version = 0;
	private int length = 0;
	private Date time = null;
	private HashMap<String, ArrayList<Float>> data = new HashMap<String, ArrayList<Float>>();
	
	public static final long MS_PER_HOUR = 60*60*1000;
	public static final int MAX_HOURS = 24;//*30+24; // A month
	
	//public AirData() {
	//}
	
	public void addData(String name, ArrayList<Float> data) {
		assert(name!=null && data!=null);
		if(length>0)
			assert(length==data.size());
		else
			length = data.size();
		this.data.put(name, data);
	}
	
	public int getLength() {
		return length;
	}
	
	public List<Float> getData(String name) {
		if(!data.containsKey(name)) return null;
		return  Collections.unmodifiableList(data.get(name));
	}
	public void setTime(Date t) {
		assert(t!=null);
		time = t;
	}
	public Date getTime() {
		return time;
	}
	public void cutTo(int hour) {
		if(hour >= length) return;
		for(ArrayList<Float> v:data.values() ) {
			v.subList(0, length - hour).clear();
		}
		length = hour;
	}
}
